/**
 * 				Sound.java
 *				------------
 *		
 *   Author:	bin04017@gmail.com
 *	 Created:	13.12.2006
 *	 Project:	MP3-Sync (Mochito)
 *	 Package:	mochito.sound
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 */
package mochito.sound;

import java.io.File;

import javazoom.jl.decoder.JavaLayerException;
import javazoom.jl.player.jlp;

/**
 * @author bin04017
 * 
 */
public class SoundItem implements Runnable{

	private jlp player = null;

	public SoundItem(File file){
		this.player = new jlp(file.getAbsolutePath());
	}
	
	public SoundItem(String fileName) {
		this.player = new jlp(fileName);
	}

	private void play() throws SoundException  {
		try {
			player.play();
		} catch (JavaLayerException e) {
			throw new SoundException("Error playing: ", e);
		}
	}

	public void run() {
		try {
			this.play();
		} catch (SoundException e) {
			System.err.println(e.toString());
		}		
	}
}
